package com.fr.report;

import com.fr.base.FRContext;
import com.fr.base.background.ColorBackground;
import com.fr.base.core.FT;
import com.fr.base.core.GraphHelper;
import com.fr.report.cellElement.CellPageAttr;
import com.fr.report.cellElement.CoverCellElement;
import com.fr.report.cellElement.Formula;
import com.fr.report.cellElement.core.CellElementAttribute;
import com.fr.report.cellElement.core.CellUtils;
import com.fr.report.cellElement.core.ResultSubReport;
import com.fr.report.core.DynamicValueList;
import com.fr.report.core.PaintUtils;
import com.fr.report.core.ReportHelper;
import com.fr.report.core.ReportUtils;
import com.fr.report.painter.PagePainter;
import com.fr.util.Utils;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D.Double;
import java.awt.image.BufferedImage;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.Serializable;
import java.sql.Clob;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;

public class ReportPage
  implements ReportGetter, Printable, Serializable
{
  private static final long serialVersionUID = 4854581643677224811L;
  protected Report source_report;
  private FT[] column_line_array;
  private FT[] row_line_array;
  private int currentPageNumber;
  private PageInfo pageInfo;
  private ReportSettings reportSettings = null;
  private com.fr.base.core.list.IntList row_height_list = null;
  private com.fr.base.core.list.IntList column_width_list = null;
  private DynamicValueList columnWidthList;
  private DynamicValueList rowHeightList;
  private int contentWidth = -1;
  private int contentHeight = -1;
  private int x;
  private int y;
  private PaperSetting paperSetting;

  public ReportPage(Report paramReport, PageInfo paramPageInfo, PaperSetting paramPaperSetting, FT[] paramArrayOfFT1, FT[] paramArrayOfFT2, int paramInt1, int paramInt2)
  {
    setPageInfo(paramPageInfo);
    this.source_report = paramReport;
    this.row_line_array = paramArrayOfFT1;
    this.column_line_array = paramArrayOfFT2;
    this.paperSetting = paramPaperSetting;
    this.x = paramInt1;
    this.y = paramInt2;
    this.columnWidthList = ReportHelper.getColumnWidthList(this.source_report);
    this.rowHeightList = ReportHelper.getRowHeightList(this.source_report);
    initRowHeightArray();
    initColumnWidthArray();
  }

  public Report getSourceReport()
  {
    return this.source_report;
  }

  public int[] getXY()
  {
    return new int[] { this.x, this.y };
  }

  private void initColumnWidthArray()
  {
    int i;
    if (this.column_width_list == null)
    {
      this.column_width_list = new com.fr.base.core.list.IntList();
      for (i = 0; i < this.column_line_array.length; ++i)
      {
        FT localFT = this.column_line_array[i];
        for (int j = localFT.from; j < localFT.to; ++j)
          this.column_width_list.add(this.source_report.getColumnWidth(j));
      }
    }
  }

  private void initRowHeightArray()
  {
    int i;
    if (this.row_height_list == null)
    {
      this.row_height_list = new com.fr.base.core.list.IntList();
      for (i = 0; i < this.row_line_array.length; ++i)
      {
        FT localFT = this.row_line_array[i];
        for (int j = localFT.from; j < localFT.to; ++j)
          this.row_height_list.add(this.source_report.getRowHeight(j));
      }
    }
  }

  public void setCurrentPageNumber(int paramInt)
  {
    this.currentPageNumber = paramInt;
  }

  public int getCurrentPageNumber()
  {
    return this.currentPageNumber;
  }

  public int getTotalPages()
  {
    return getPageInfo().getTotalPages();
  }

  public void setPageInfo(PageInfo paramPageInfo)
  {
    this.pageInfo = paramPageInfo;
  }

  public PageInfo getPageInfo()
  {
    return this.pageInfo;
  }

  public ReportHF getHeader()
  {
    ReportHF localReportHF = null;
    if (this.currentPageNumber == 1)
      localReportHF = getHeader(1);
    if (localReportHF != null)
      return localReportHF;
    if (this.currentPageNumber == getTotalPages())
      localReportHF = getHeader(2);
    if (localReportHF != null)
      return localReportHF;
    if (this.currentPageNumber % 2 != 0)
      localReportHF = getHeader(3);
    if (localReportHF != null)
      return localReportHF;
    if (this.currentPageNumber % 2 == 0)
      localReportHF = getHeader(4);
    if (localReportHF != null)
      return localReportHF;
    return getHeader(0);
  }

  public ReportHF getFooter()
  {
    ReportHF localReportHF = null;
    if (this.currentPageNumber == 1)
      localReportHF = getFooter(1);
    if (localReportHF != null)
      return localReportHF;
    if (this.currentPageNumber == getTotalPages())
      localReportHF = getFooter(2);
    if (localReportHF != null)
      return localReportHF;
    if (this.currentPageNumber % 2 != 0)
      localReportHF = getFooter(3);
    if (localReportHF != null)
      return localReportHF;
    if (this.currentPageNumber % 2 == 0)
      localReportHF = getFooter(4);
    if (localReportHF != null)
      return localReportHF;
    return getFooter(0);
  }

  public int print(Graphics paramGraphics, PageFormat paramPageFormat, int paramInt)
    throws PrinterException
  {
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics.create();
    localGraphics2D.translate(paramPageFormat.getImageableX(), paramPageFormat.getImageableY());
    ReportSettings localReportSettings = this.source_report.getReportSettings();
    if (localReportSettings.isLonelyPage())
    {
      DynamicValueList localDynamicValueList1 = ReportHelper.getColumnWidthList(this.source_report);
      DynamicValueList localDynamicValueList2 = ReportHelper.getRowHeightList(this.source_report);
      int i = this.source_report.getColumnCount();
      int j = this.source_report.getRowCount();
      int k = 0;
      int l = 0;
      for (int i1 = 0; i1 < i; ++i1)
        k += localDynamicValueList1.get(i1);
      for (i1 = 0; i1 < j; ++i1)
        l += localDynamicValueList2.get(i1);
      d1 = getPageWidth() / (getMarginLeft() + getMarginRight() + k);
      d2 = getPageHeight() / (l + getMarginTop() + getMarginBottom());
      d1 = (d1 < 1.0D) ? d1 : 1.0D;
      d2 = (d2 < 1.0D) ? d2 : 1.0D;
      localGraphics2D.scale(d1, d2);
    }
    double d1 = this.source_report.getReportSettings().getResolution() / 72.0D;
    double d2 = d1 * paramPageFormat.getImageableWidth() / getPageWidth();
    double d3 = d1 * paramPageFormat.getImageableHeight() / getPageHeight();
    double d4 = Math.min(d2, d3);
    if (d4 < 1.0D)
      localGraphics2D.scale(d4, d4);
    new PagePainter(this, localGraphics2D, true).convert();
    return 0;
  }

  public Iterator cellIterator(Rectangle paramRectangle)
  {
    return this.source_report.intersect(paramRectangle.x, paramRectangle.y, paramRectangle.width, paramRectangle.height);
  }

  public Iterator floatIterator(Rectangle paramRectangle)
  {
    return this.source_report.floatIterator();
  }

  public Image toImage()
  {
    return toImage(true);
  }

  public Image toImage(boolean paramBoolean)
  {
    int i = getPageWidth();
    int j = getPageHeight();
    BufferedImage localBufferedImage = GraphHelper.createBufferedImage(i, j, 2);
    Graphics2D localGraphics2D = localBufferedImage.createGraphics();
    new PagePainter(this, localGraphics2D, paramBoolean).convert();
    return localBufferedImage;
  }

  public int getColumnWidth(int paramInt)
  {
    return this.column_width_list.get(paramInt);
  }

  public int getRowHeight(int paramInt)
  {
    return this.row_height_list.get(paramInt);
  }

  public Iterator cellIterator()
  {
    return new PageCellIterator(this, null);
  }

  public int getColumnCount()
  {
    return this.column_width_list.size();
  }

  public Iterator getRow(int paramInt)
  {
    return new PageRowIterator(this, paramInt, null);
  }

  public int getRowCount()
  {
    return this.row_height_list.size();
  }

  public Iterator floatIterator()
  {
    return new PageFloatIterator(this, null);
  }

  public ReportHF getFooter(int paramInt)
  {
    return this.source_report.getFooter(paramInt);
  }

  public ReportHF getHeader(int paramInt)
  {
    return this.source_report.getHeader(paramInt);
  }

  public ReportPageAttr getReportPageAttr()
  {
    return this.source_report.getReportPageAttr();
  }

  public ReportSettings getReportSettings()
  {
    if (this.reportSettings == null)
      this.reportSettings = ReportUtils.getReportSettings(this.source_report);
    return this.reportSettings;
  }

  public int getPageWidth()
  {
    if (this.paperSetting != null)
      return ReportUtils.getPaperWidth(this.paperSetting);
    return getContentWidth();
  }

  public int getPageHeight()
  {
    if (this.paperSetting != null)
      return ReportUtils.getPaperHeight(this.paperSetting);
    return getContentHeight();
  }

  public int getMarginTop()
  {
    if (this.paperSetting != null)
      return ReportUtils.getMarginTop(this.paperSetting);
    return 0;
  }

  public int getMarginLeft()
  {
    if (this.paperSetting != null)
      return ReportUtils.getMarginLeft(this.paperSetting);
    return 0;
  }

  public int getMarginBottom()
  {
    if (this.paperSetting != null)
      return ReportUtils.getMarginBottom(this.paperSetting);
    return 0;
  }

  public int getMarginRight()
  {
    if (this.paperSetting != null)
      return ReportUtils.getMarginRight(this.paperSetting);
    return 0;
  }

  public synchronized int getContentWidth()
  {
    if (this.contentWidth == -1)
    {
      DynamicValueList localDynamicValueList = ReportHelper.createColumnWidthList(this);
      this.contentWidth = Math.max(localDynamicValueList.getRangeValueFromZero(getColumnCount()), 1);
      Iterator localIterator = floatIterator();
      while (localIterator.hasNext())
      {
        FloatElement localFloatElement = (FloatElement)localIterator.next();
        int i = localDynamicValueList.getRangeValueFromZero(localFloatElement.getColumn()) + localFloatElement.getLeftDistance();
        int j = localFloatElement.getSize().width + 1;
        this.contentWidth = Math.max(this.contentWidth, i + j);
      }
    }
    return this.contentWidth;
  }

  public synchronized int getContentHeight()
  {
    if (this.contentHeight == -1)
    {
      DynamicValueList localDynamicValueList = ReportHelper.createRowHeightList(this);
      this.contentHeight = Math.max(localDynamicValueList.getRangeValueFromZero(getRowCount()), 1);
      Iterator localIterator = floatIterator();
      while (localIterator.hasNext())
      {
        FloatElement localFloatElement = (FloatElement)localIterator.next();
        int i = localDynamicValueList.getRangeValueFromZero(localFloatElement.getRow()) + localFloatElement.getTopDistance();
        int j = localFloatElement.getSize().height + 1;
        this.contentHeight = Math.max(this.contentHeight, i + j);
      }
    }
    return this.contentHeight;
  }

  public PageFormat getPageFormat(PageFormat paramPageFormat)
  {
    if (paramPageFormat == null)
      paramPageFormat = new PageFormat();
    else
      paramPageFormat = (PageFormat)paramPageFormat.clone();
    ReportSettings localReportSettings = getReportSettings();
    int i = localReportSettings.getOrientation();
    PaperSize localPaperSize = localReportSettings.getPaperSize();
    Paper localPaper = paramPageFormat.getPaper();
    localPaper.setSize(localPaperSize.getWidth() * 72.0D, localPaperSize.getHeight() * 72.0D);
    localPaper.setImageableArea(0.0D, 0.0D, localPaperSize.getWidth() * 72.0D, localPaperSize.getHeight() * 72.0D);
    paramPageFormat.setPaper(localPaper);
    if (i == 1)
      paramPageFormat.setOrientation(0);
    else
      paramPageFormat.setOrientation(1);
    return paramPageFormat;
  }

  private void checkCellElementValue(CellElement paramCellElement1, CellElement paramCellElement2, Rectangle paramRectangle1, Rectangle paramRectangle2, Rectangle paramRectangle3, Rectangle paramRectangle4)
  {
    Object localObject2;
    Object localObject3;
    Object localObject1 = paramCellElement1.getValue();
    if (localObject1 instanceof Formula)
    {
      localObject2 = (Formula)localObject1;
      localObject1 = ((Formula)localObject2).getResult();
      paramCellElement1.setValue(localObject1);
    }
    if (localObject1 instanceof String)
    {
      localObject2 = applyPageNumber2String((String)localObject1);
      if (!(localObject1.equals(localObject2)))
      {
        localObject1 = localObject2;
        paramCellElement1.setValue(localObject1);
      }
    }
    if (paramCellElement2.getPresent() != null)
      paramCellElement1.setValue(paramCellElement2.getAttribute(CellElementAttribute.PRESENT_VALUE));
    if (localObject1 instanceof byte[])
    {
      localObject2 = paramCellElement2.getAttribute(CellElementAttribute.ATT_TYPE);
      if ((localObject2 != null) && ("image".equals((String)localObject2)))
        try
        {
          paramCellElement1.setValue(ImageIO.read(new ByteArrayInputStream((byte[])localObject1)));
        }
        catch (IOException localIOException)
        {
          FRContext.getLogger().log(Level.WARNING, localIOException.getMessage(), localIOException);
        }
    }
    else if (localObject1 instanceof ResultSubReport)
    {
      localObject2 = new Rectangle(this.columnWidthList.getRangeValue(paramRectangle1.x, paramRectangle2.x), this.rowHeightList.getRangeValue(paramRectangle1.y, paramRectangle2.y), this.columnWidthList.getRangeValue(paramCellElement2.getColumn(), paramCellElement2.getColumn() + paramCellElement2.getColumnSpan()), this.rowHeightList.getRangeValue(paramCellElement2.getRow(), paramCellElement2.getRow() + paramCellElement2.getRowSpan()));
      localObject3 = new Rectangle(this.columnWidthList.getRangeValue(paramRectangle2.x, paramRectangle1.x), this.rowHeightList.getRangeValue(paramRectangle2.y, paramRectangle1.y), this.columnWidthList.getRangeValue(paramRectangle1.x, paramRectangle1.x + paramRectangle1.width), this.rowHeightList.getRangeValue(paramRectangle1.y, paramRectangle1.y + paramRectangle1.height));
      paramCellElement1.setValue(CellUtils.value2Image(localObject1, paramCellElement1.getStyle(), (Rectangle)localObject2, (Rectangle)localObject3));
    }
    localObject1 = paramCellElement1.getValue();
    if ((paramRectangle3 != null) && (((localObject1 instanceof String) || (localObject1 instanceof Clob))))
    {
      if (localObject1 instanceof Clob)
        localObject1 = Utils.clob2String((Clob)localObject1);
      int i = ((paramCellElement2.getCellGUIAttr() != null) && (paramCellElement2.getCellGUIAttr().isShowAsHTML())) ? 1 : 0;
      localObject3 = GraphHelper.createBufferedImage(paramRectangle4.width, paramRectangle4.height, 2);
      Graphics2D localGraphics2D = ((BufferedImage)localObject3).createGraphics();
      localGraphics2D.setPaint(Color.white);
      ColorBackground.getInstance(Color.white).paint(localGraphics2D, new Rectangle2D.Double(0.0D, 0.0D, paramRectangle4.width, paramRectangle4.height));
      if (i != 0)
        PaintUtils.paintHTMLContent(localGraphics2D, (String)localObject1, paramCellElement2.getStyle(), paramRectangle3, paramRectangle4);
      else
        PaintUtils.paintContent(localGraphics2D, localObject1, paramCellElement2.getStyle(), paramRectangle3, paramRectangle4);
      ((BufferedImage)localObject3).flush();
      localGraphics2D.dispose();
      paramCellElement1.setValue(localObject3);
    }
  }

  private Object applyPageNumber2String(String paramString)
  {
    if ((paramString.indexOf("$$totalPage_number") > -1) || (paramString.indexOf("$$page_number") > -1))
      return Utils.replaceAllString(Utils.replaceAllString(paramString, "$$totalPage_number", String.valueOf(getTotalPages())), "$$page_number", String.valueOf(getCurrentPageNumber()));
    return paramString;
  }

  static FT[] access$300(ReportPage paramReportPage)
  {
    return paramReportPage.row_line_array;
  }

  static FT[] access$400(ReportPage paramReportPage)
  {
    return paramReportPage.column_line_array;
  }

  static DynamicValueList access$500(ReportPage paramReportPage)
  {
    return paramReportPage.columnWidthList;
  }

  static DynamicValueList access$600(ReportPage paramReportPage)
  {
    return paramReportPage.rowHeightList;
  }

  static void access$700(ReportPage paramReportPage, CellElement paramCellElement1, CellElement paramCellElement2, Rectangle paramRectangle1, Rectangle paramRectangle2, Rectangle paramRectangle3, Rectangle paramRectangle4)
  {
    paramReportPage.checkCellElementValue(paramCellElement1, paramCellElement2, paramRectangle1, paramRectangle2, paramRectangle3, paramRectangle4);
  }

  private class PageFloatIterator
    implements Iterator
  {
    private Iterator current_it;
    private FloatElement next;
    private final ReportPage this$0;

    private PageFloatIterator()
    {
      this.this$0 = paramReportPage;
      this.next = null;
      this.current_it = paramReportPage.source_report.floatIterator();
      findNext();
    }

    public boolean hasNext()
    {
      return (this.next != null);
    }

    public Object next()
    {
      if (!(hasNext()))
        throw new NoSuchElementException("At last element");
      FloatElement localFloatElement = this.next;
      findNext();
      return localFloatElement;
    }

    public void remove()
    {
      throw new UnsupportedOperationException();
    }

    private void findNext()
    {
      if (this.current_it.hasNext())
      {
        java.awt.Point localPoint = new java.awt.Point(0, 0);
        FloatElement localFloatElement1 = (FloatElement)this.current_it.next();
        int i = 0;
        while (true)
        {
          if (i >= ReportPage.access$400(this.this$0).length);
          FT localFT1 = ReportPage.access$400(this.this$0)[i];
          for (int j = 0; j < ReportPage.access$300(this.this$0).length; ++j)
          {
            FT localFT2 = ReportPage.access$300(this.this$0)[j];
            Rectangle localRectangle1 = new Rectangle(localFT1.from, localFT2.from, localFT1.to - localFT1.from, localFT2.to - localFT2.from);
            Rectangle localRectangle2 = new Rectangle(ReportPage.access$500(this.this$0).getRangeValueFromZero(localRectangle1.x), ReportPage.access$600(this.this$0).getRangeValueFromZero(localRectangle1.y), ReportPage.access$500(this.this$0).getRangeValue(localRectangle1.x, localRectangle1.x + localRectangle1.width), ReportPage.access$600(this.this$0).getRangeValue(localRectangle1.y, localRectangle1.y + localRectangle1.height));
            FloatElement localFloatElement2 = intersectFloatElement(localFloatElement1, localRectangle1, localRectangle2, localPoint, ReportPage.access$500(this.this$0), ReportPage.access$600(this.this$0));
            if (localFloatElement2 != null)
            {
              this.next = localFloatElement2;
              return;
            }
            localPoint.y += localFT2.to - localFT2.from;
          }
          localPoint.y = 0;
          localPoint.x += localFT1.to - localFT1.from;
          ++i;
        }
      }
      this.next = null;
    }

    private FloatElement intersectFloatElement(, Rectangle paramRectangle1, Rectangle paramRectangle2, java.awt.Point paramPoint, DynamicValueList paramDynamicValueList1, DynamicValueList paramDynamicValueList2)
    {
      int i = paramFloatElement.getColumn();
      int j = paramFloatElement.getRow();
      Rectangle localRectangle1 = new Rectangle(paramDynamicValueList1.getRangeValueFromZero(i) + paramFloatElement.getLeftDistance(), paramDynamicValueList2.getRangeValueFromZero(j) + paramFloatElement.getTopDistance(), paramFloatElement.getSize().width, paramFloatElement.getSize().height);
      Rectangle localRectangle2 = paramRectangle2.intersection(localRectangle1);
      if ((localRectangle2.width > 0) && (localRectangle2.height > 0))
      {
        int k = 0;
        int l = 0;
        int i1 = 0;
        int i2 = 0;
        while (i1 + (i3 = paramDynamicValueList1.get(k)) <= localRectangle2.x)
        {
          int i3;
          i1 += i3;
          ++k;
        }
        while (i2 + (i4 = paramDynamicValueList2.get(l)) <= localRectangle2.y)
        {
          int i4;
          i2 += i4;
          ++l;
        }
        try
        {
          paramFloatElement = paramFloatElement.deriveFloatElement(paramPoint.x + k - paramRectangle1.x, paramPoint.y + l - paramRectangle1.y, localRectangle2.x - i1, localRectangle2.y - i2, new Dimension(localRectangle2.width, localRectangle2.height));
        }
        catch (CloneNotSupportedException localCloneNotSupportedException)
        {
          FRContext.getLogger().log(Level.WARNING, localCloneNotSupportedException.getMessage(), localCloneNotSupportedException);
          paramFloatElement.setColumn(paramPoint.x + k - paramRectangle1.x);
          paramFloatElement.setRow(paramPoint.y + l - paramRectangle1.y);
          paramFloatElement.setLeftDistance(localRectangle2.x - i1);
          paramFloatElement.setTopDistance(localRectangle2.y - i2);
          paramFloatElement.setSize(new Dimension(localRectangle2.width, localRectangle2.height));
        }
        return paramFloatElement;
      }
      return null;
    }

    PageFloatIterator(, ReportPage.1 param1)
    {
      this(paramReportPage);
    }
  }

  private class PageRowIterator
    implements Iterator
  {
    private int current_ri;
    private int row_offset;
    private int current_ci;
    private Cell next;
    private Iterator current_it;
    private java.awt.Point offsetColumnRow;
    private final ReportPage this$0;

    private PageRowIterator(, int paramInt)
    {
      this.this$0 = paramReportPage;
      this.current_ri = -1;
      this.row_offset = -1;
      this.current_ci = 0;
      this.next = null;
      int i = paramInt;
      for (int j = 0; j < ReportPage.access$300(paramReportPage).length; ++j)
      {
        FT localFT = ReportPage.access$300(paramReportPage)[j];
        int k = localFT.to - localFT.from;
        if (k > i)
        {
          this.current_ri = j;
          this.row_offset = i;
          break;
        }
        i -= k;
      }
      this.offsetColumnRow = new java.awt.Point(0, paramInt - i);
      findNext();
    }

    public boolean hasNext()
    {
      return (this.next != null);
    }

    public Object next()
    {
      if (!(hasNext()))
        throw new NoSuchElementException("At last element");
      Cell localCell = this.next;
      findNext();
      return localCell;
    }

    public void remove()
    {
      throw new UnsupportedOperationException();
    }

    private void findNext()
    {
      if (this.current_ri == -1)
        return;
      FT localFT1 = ReportPage.access$300(this.this$0)[this.current_ri];
      for (int i = this.current_ci; i < ReportPage.access$400(this.this$0).length; ++i)
      {
        Object localObject;
        Cell localCell;
        this.current_ci = i;
        FT localFT2 = ReportPage.access$400(this.this$0)[i];
        Rectangle localRectangle = new Rectangle(localFT2.from, localFT1.from, localFT2.to - localFT2.from, localFT1.to - localFT1.from);
        if (this.current_it == null)
        {
          localObject = new Rectangle(localFT2.from, localFT1.from + this.row_offset, localFT2.to - localFT2.from, 1);
          this.current_it = this.this$0.cellIterator((Rectangle)localObject);
        }
        do
        {
          while (true)
          {
            if (!(this.current_it.hasNext()))
              break label250;
            localObject = (CellElement)this.current_it.next();
            if ((this.row_offset <= 0) || (((CellElement)localObject).getRow() >= localFT1.from + this.row_offset))
              break;
          }
          localCell = intersectCell((CellElement)localObject, localRectangle, this.offsetColumnRow, ReportPage.access$400(this.this$0), ReportPage.access$300(this.this$0), ReportPage.access$500(this.this$0), ReportPage.access$600(this.this$0));
        }
        while (localCell == null);
        this.next = localCell;
        return;
        this.current_it = null;
        this.offsetColumnRow.x += localFT2.to - localFT2.from;
      }
      label250: this.next = null;
    }

    private Cell intersectCell(, Rectangle paramRectangle, java.awt.Point paramPoint, FT[] paramArrayOfFT1, FT[] paramArrayOfFT2, DynamicValueList paramDynamicValueList1, DynamicValueList paramDynamicValueList2)
    {
      Rectangle localRectangle1 = new Rectangle(paramCellElement.getColumn(), paramCellElement.getRow(), paramCellElement.getColumnSpan(), paramCellElement.getRowSpan());
      Rectangle localRectangle2 = localRectangle1.intersection(paramRectangle);
      CoverCellElement localCoverCellElement = null;
      CellPageAttr localCellPageAttr = paramCellElement.getCellPageAttr();
      if (localCellPageAttr == null)
        localCellPageAttr = CellPageAttr.DEFAULT_CELLPAGEATTR;
      int i = ((localCellPageAttr.isRepeat()) && (!(paramCellElement.getValue() instanceof ResultSubReport))) ? 1 : 0;
      Rectangle localRectangle3 = null;
      Rectangle localRectangle4 = null;
      if (!(localRectangle2.equals(localRectangle1)))
      {
        FT localFT;
        if (i == 0)
        {
          localRectangle3 = new Rectangle(paramDynamicValueList1.getRangeValue(localRectangle2.x, localRectangle1.x), paramDynamicValueList2.getRangeValue(localRectangle2.y, localRectangle1.y), paramDynamicValueList1.getRangeValue(localRectangle1.x, localRectangle1.x + localRectangle1.width), paramDynamicValueList2.getRangeValue(localRectangle1.y, localRectangle1.y + localRectangle1.height));
          localRectangle4 = new Rectangle(-localRectangle3.x, -localRectangle3.y, paramDynamicValueList1.getRangeValue(localRectangle2.x, localRectangle2.x + localRectangle2.width), paramDynamicValueList2.getRangeValue(localRectangle2.y, localRectangle2.y + localRectangle2.height));
        }
        int j = 0;
        int k = 0;
        int l = 0;
        for (int i1 = 0; i1 < paramArrayOfFT1.length; ++i1)
        {
          localFT = paramArrayOfFT1[i1];
          if ((localRectangle1.x < localFT.to) && (localFT.from < localRectangle1.x + localRectangle1.width))
          {
            if (this.current_ci > i1)
              return null;
            ++j;
            k += Math.min(localFT.to, localRectangle1.x + localRectangle1.width) - Math.max(localRectangle1.x, localFT.from);
          }
        }
        for (i1 = 0; i1 < paramArrayOfFT2.length; ++i1)
        {
          localFT = paramArrayOfFT2[i1];
          if ((localRectangle1.y < localFT.to) && (localFT.from < localRectangle1.y + localRectangle1.height))
          {
            if (this.current_ri > i1)
              return null;
            ++j;
            l += Math.min(localFT.to, localRectangle1.y + localRectangle1.height) - Math.max(localRectangle1.y, localFT.from);
          }
        }
        if (j > 1)
        {
          if (k == 0)
            k = localRectangle2.width;
          if (l == 0)
            l = localRectangle2.height;
          localCoverCellElement = new CoverCellElement(paramCellElement, paramPoint.x + localRectangle2.x - paramRectangle.x, paramPoint.y + localRectangle2.y - paramRectangle.y, k, l);
        }
      }
      if (localCoverCellElement == null)
        localCoverCellElement = new CoverCellElement(paramCellElement, paramPoint.x + localRectangle2.x - paramRectangle.x, paramPoint.y + localRectangle2.y - paramRectangle.y, localRectangle2.width, localRectangle2.height);
      ReportPage.access$700(this.this$0, localCoverCellElement, paramCellElement, localRectangle2, localRectangle1, localRectangle3, localRectangle4);
      return localCoverCellElement;
    }

    PageRowIterator(, int paramInt, ReportPage.1 param1)
    {
      this(paramReportPage, paramInt);
    }
  }

  private class PageCellIterator
    implements Iterator
  {
    private int current_ri;
    private int current_row;
    private int current_ci;
    private Iterator current_it;
    private Cell next;
    private java.awt.Point offsetColumnRow;
    private List mergedCellList;
    private final ReportPage this$0;

    private PageCellIterator()
    {
      this.this$0 = paramReportPage;
      this.current_ri = 0;
      this.current_row = 0;
      this.current_ci = 0;
      this.current_it = null;
      this.next = null;
      this.offsetColumnRow = new java.awt.Point(0, 0);
      this.mergedCellList = new ArrayList();
      findNext();
    }

    public boolean hasNext()
    {
      return (this.next != null);
    }

    public Object next()
    {
      if (!(hasNext()))
        throw new NoSuchElementException("At last element");
      Cell localCell = this.next;
      findNext();
      return localCell;
    }

    public void remove()
    {
      throw new UnsupportedOperationException();
    }

    private void findNext()
    {
      for (int i = this.current_ri; i < ReportPage.access$300(this.this$0).length; ++i)
      {
        FT localFT1 = ReportPage.access$300(this.this$0)[i];
        this.current_ri = i;
        for (int j = this.current_row; j < localFT1.to - localFT1.from; ++j)
        {
          this.current_row = j;
          for (int k = this.current_ci; k < ReportPage.access$400(this.this$0).length; ++k)
          {
            Object localObject;
            Cell localCell;
            this.current_ci = k;
            FT localFT2 = ReportPage.access$400(this.this$0)[k];
            Rectangle localRectangle = new Rectangle(localFT2.from, localFT1.from, localFT2.to - localFT2.from, localFT1.to - localFT1.from);
            if (this.current_it == null)
            {
              localObject = new Rectangle(localFT2.from, localFT1.from + j, localFT2.to - localFT2.from, 1);
              this.current_it = this.this$0.cellIterator((Rectangle)localObject);
            }
            do
            {
              while (true)
              {
                if (!(this.current_it.hasNext()))
                  break label285;
                localObject = (CellElement)this.current_it.next();
                if ((j <= 0) || (((CellElement)localObject).getRow() >= localFT1.from + j))
                  break;
              }
              localCell = intersectCell((CellElement)localObject, localRectangle, this.offsetColumnRow, ReportPage.access$400(this.this$0), ReportPage.access$300(this.this$0), ReportPage.access$500(this.this$0), ReportPage.access$600(this.this$0));
            }
            while (localCell == null);
            this.next = localCell;
            return;
            this.current_it = null;
            this.offsetColumnRow.x += localFT2.to - localFT2.from;
          }
          this.current_ci = 0;
          this.offsetColumnRow.x = 0;
        }
        this.current_row = 0;
        this.offsetColumnRow.y += localFT1.to - localFT1.from;
      }
      label285: this.next = null;
    }

    private Cell intersectCell(, Rectangle paramRectangle, java.awt.Point paramPoint, FT[] paramArrayOfFT1, FT[] paramArrayOfFT2, DynamicValueList paramDynamicValueList1, DynamicValueList paramDynamicValueList2)
    {
      Rectangle localRectangle1 = new Rectangle(paramCellElement.getColumn(), paramCellElement.getRow(), paramCellElement.getColumnSpan(), paramCellElement.getRowSpan());
      Rectangle localRectangle2 = localRectangle1.intersection(paramRectangle);
      CoverCellElement localCoverCellElement = null;
      CellPageAttr localCellPageAttr = paramCellElement.getCellPageAttr();
      if (localCellPageAttr == null)
        localCellPageAttr = CellPageAttr.DEFAULT_CELLPAGEATTR;
      int i = ((localCellPageAttr.isRepeat()) && (!(paramCellElement.getValue() instanceof ResultSubReport))) ? 1 : 0;
      Rectangle localRectangle3 = null;
      Rectangle localRectangle4 = null;
      Rectangle localRectangle5 = null;
      Rectangle localRectangle6 = null;
      if (!(localRectangle2.equals(localRectangle1)))
      {
        FT localFT;
        if (i == 0)
        {
          localRectangle5 = new Rectangle(paramDynamicValueList1.getRangeValue(paramRectangle.x, localRectangle1.x), paramDynamicValueList2.getRangeValue(paramRectangle.y, localRectangle1.y), paramDynamicValueList1.getRangeValue(localRectangle1.x, localRectangle1.x + localRectangle1.width), paramDynamicValueList2.getRangeValue(localRectangle1.y, localRectangle1.y + localRectangle1.height));
          j = 0;
          if (paramRectangle.x > localRectangle1.x)
            j = paramDynamicValueList1.getRangeValue(localRectangle1.x, paramRectangle.x);
          k = paramDynamicValueList1.getRangeValue(localRectangle2.x, localRectangle2.x + localRectangle2.width);
          l = 0;
          if (paramRectangle.y > localRectangle1.y)
            l = paramDynamicValueList2.getRangeValue(localRectangle1.y, paramRectangle.y);
          i1 = paramDynamicValueList2.getRangeValue(localRectangle2.y, localRectangle2.y + localRectangle2.height);
          localRectangle6 = new Rectangle(j, l, k, i1);
          localRectangle3 = new Rectangle(paramDynamicValueList1.getRangeValue(localRectangle2.x, localRectangle1.x), paramDynamicValueList2.getRangeValue(localRectangle2.y, localRectangle1.y), paramDynamicValueList1.getRangeValue(localRectangle1.x, localRectangle1.x + localRectangle1.width), paramDynamicValueList2.getRangeValue(localRectangle1.y, localRectangle1.y + localRectangle1.height));
          localRectangle4 = new Rectangle(-localRectangle3.x, -localRectangle3.y, paramDynamicValueList1.getRangeValue(localRectangle2.x, localRectangle2.x + localRectangle2.width), paramDynamicValueList2.getRangeValue(localRectangle2.y, localRectangle2.y + localRectangle2.height));
        }
        if (this.mergedCellList.contains(paramCellElement))
          return null;
        int j = 0;
        int k = 0;
        int l = 0;
        for (int i1 = 0; i1 < paramArrayOfFT1.length; ++i1)
        {
          localFT = paramArrayOfFT1[i1];
          if ((localRectangle1.x < localFT.to) && (localFT.from < localRectangle1.x + localRectangle1.width))
          {
            ++j;
            k += Math.min(localFT.to, localRectangle1.x + localRectangle1.width) - Math.max(localRectangle1.x, localFT.from);
          }
        }
        for (i1 = 0; i1 < paramArrayOfFT2.length; ++i1)
        {
          localFT = paramArrayOfFT2[i1];
          if ((localRectangle1.y < localFT.to) && (localFT.from < localRectangle1.y + localRectangle1.height))
          {
            ++j;
            l += Math.min(localFT.to, localRectangle1.y + localRectangle1.height) - Math.max(localRectangle1.y, localFT.from);
          }
        }
        if (j > 1)
        {
          this.mergedCellList.add(paramCellElement);
          if (k == 0)
            k = localRectangle2.width;
          if (l == 0)
            l = localRectangle2.height;
          localCoverCellElement = new CoverCellElement(paramCellElement, paramPoint.x + localRectangle2.x - paramRectangle.x, paramPoint.y + localRectangle2.y - paramRectangle.y, k, l);
        }
      }
      if (localCoverCellElement == null)
        localCoverCellElement = new CoverCellElement(paramCellElement, paramPoint.x + localRectangle2.x - paramRectangle.x, paramPoint.y + localRectangle2.y - paramRectangle.y, localRectangle2.width, localRectangle2.height);
      if (localRectangle5 != null)
        localCoverCellElement.setCellPaintInfo(localRectangle5, localRectangle6, paramCellElement.getValue());
      ReportPage.access$700(this.this$0, localCoverCellElement, paramCellElement, localRectangle2, localRectangle1, localRectangle3, localRectangle4);
      return localCoverCellElement;
    }

    PageCellIterator(, ReportPage.1 param1)
    {
      this(paramReportPage);
    }
  }
}